package com.dynamixsoftware.printershare;

import android.content.Intent;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeMap;
import java.util.Vector;

public class ActivityDriversBrowser
  extends ActivityRoot
{
  private FolderAdapter adapter;
  private volatile Vector<Entry> data;
  private ListView list;
  private Thread wt;
  
  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    this.data = new Vector();
    this.adapter = new FolderAdapter();
    float f = getResources().getDisplayMetrics().density;
    this.list = new ListView(this);
    this.list.setPadding(0, (int)(5.0F * f), 0, 0);
    this.list.setAdapter(this.adapter);
    this.list.setCacheColorHint(0);
    this.list.setOnItemClickListener(new AdapterView.OnItemClickListener()
    {
      public void onItemClick(AdapterView<?> paramAnonymousAdapterView, View paramAnonymousView, int paramAnonymousInt, long paramAnonymousLong)
      {
        int i = ((Integer)paramAnonymousView.getTag()).intValue();
        ActivityDriversBrowser.Entry localEntry1 = (ActivityDriversBrowser.Entry)ActivityDriversBrowser.this.adapter.getItem(i);
        if (localEntry1.data != null)
        {
          if (!"..".equals(localEntry1.name))
          {
            ActivityDriversBrowser.this.adapter.changeFolder(localEntry1);
            return;
          }
          ActivityDriversBrowser.FolderAdapter localFolderAdapter = ActivityDriversBrowser.this.adapter;
          if (ActivityDriversBrowser.FolderAdapter.access$100(ActivityDriversBrowser.this.adapter).size() > 1) {}
          for (ActivityDriversBrowser.Entry localEntry2 = (ActivityDriversBrowser.Entry)ActivityDriversBrowser.FolderAdapter.access$100(ActivityDriversBrowser.this.adapter).get(-2 + ActivityDriversBrowser.FolderAdapter.access$100(ActivityDriversBrowser.this.adapter).size());; localEntry2 = null)
          {
            localFolderAdapter.changeFolder(localEntry2);
            return;
          }
        }
        Bundle localBundle = new Bundle();
        localBundle.putString("model", localEntry1.name);
        Intent localIntent = new Intent();
        localIntent.putExtras(localBundle);
        ActivityDriversBrowser.this.setResult(-1, localIntent);
        ActivityDriversBrowser.this.finish();
      }
    });
    setContentView(this.list);
    setTitle(2131099681);
    showProgress(getResources().getString(2131099746));
    this.wt = new Thread()
    {
      public void run()
      {
        TreeMap localTreeMap = new TreeMap();
        for (int i = 0; i < ActivityCore.generic_models.length; i++)
        {
          String str16 = "Generic " + ActivityCore.generic_models[i];
          localTreeMap.put(str16.toLowerCase(), str16);
        }
        for (int j = 0; j < ActivityCore.brother_models.length; j++)
        {
          String str15 = "Brother " + ActivityCore.brother_models[j];
          localTreeMap.put(str15.toLowerCase(), str15);
        }
        for (int k = 0; k < ActivityCore.brother_pjmw_models.length; k++)
        {
          String str14 = "Brother " + ActivityCore.brother_pjmw_models[k];
          localTreeMap.put(str14.toLowerCase(), str14);
        }
        for (int m = 0; m < ActivityCore.able_models.length; m++)
        {
          String str13 = "Able " + ActivityCore.able_models[m];
          localTreeMap.put(str13.toLowerCase(), str13);
        }
        for (int n = 0; n < ActivityCore.canon_models.length; n++)
        {
          String str12 = "Canon " + ActivityCore.canon_models[n];
          localTreeMap.put(str12.toLowerCase(), str12);
        }
        for (int i1 = 0; i1 < ActivityCore.kodak_gziptok_models.length; i1++)
        {
          String str11 = "KODAK " + ActivityCore.kodak_gziptok_models[i1];
          localTreeMap.put(str11.toLowerCase(), str11);
        }
        for (int i2 = 0; i2 < ActivityCore.kodak_jbig_models.length; i2++)
        {
          String str10 = "KODAK " + ActivityCore.kodak_jbig_models[i2];
          localTreeMap.put(str10.toLowerCase(), str10);
        }
        for (int i3 = 0; i3 < ActivityCore.kyocera_pcl5e_models.length; i3++)
        {
          String str9 = "Kyocera " + ActivityCore.kyocera_pcl5e_models[i3];
          localTreeMap.put(str9.toLowerCase(), str9);
        }
        for (int i4 = 0; i4 < ActivityCore.kyocera_pcl5c_models.length; i4++)
        {
          String str8 = "Kyocera " + ActivityCore.kyocera_pcl5c_models[i4];
          localTreeMap.put(str8.toLowerCase(), str8);
        }
        for (int i5 = 0; i5 < ActivityCore.oki_ml_9pin_models.length; i5++)
        {
          String str7 = "OKI ML " + ActivityCore.oki_ml_9pin_models[i5];
          localTreeMap.put(str7.toLowerCase(), str7);
        }
        AssetManager localAssetManager = ActivityDriversBrowser.this.getAssets();
        int i6 = 0;
        if (i6 < ActivityCore.ext_drivers.length) {}
        for (;;)
        {
          BufferedReader localBufferedReader;
          int i11;
          try
          {
            localBufferedReader = new BufferedReader(new InputStreamReader(localAssetManager.open("data/" + ActivityCore.ext_drivers[i6] + ".dat")), 8192);
            localBufferedReader.readLine();
            localBufferedReader.readLine();
            String str3 = localBufferedReader.readLine();
            if ((str3 != null) && (str3.length() > 0))
            {
              String str4 = str3.substring(0, str3.indexOf("|"));
              i11 = -1;
              int i12 = i11 + 1;
              i11 = str4.indexOf(";", i12);
              String str5;
              if (i11 < 0)
              {
                str5 = str4.substring(i12);
                if (str5.startsWith("*")) {
                  break label1680;
                }
              }
              else
              {
                str5 = str4.substring(i12, i11);
                continue;
              }
              String str6 = str5.toLowerCase();
              if (localTreeMap.get(str6) != null) {
                break label1680;
              }
              localTreeMap.put(str6, str5);
            }
          }
          catch (Exception localException)
          {
            localException.printStackTrace();
            App.reportThrowable(localException);
          }
          for (;;)
          {
            i6++;
            break;
            localBufferedReader.close();
          }
          Vector localVector = new Vector();
          Iterator localIterator = localTreeMap.keySet().iterator();
          while (localIterator.hasNext())
          {
            String str1 = (String)localIterator.next();
            ActivityDriversBrowser.Entry localEntry1 = new ActivityDriversBrowser.Entry((String)localTreeMap.get(str1), false);
            label859:
            int i7 = -1 + localVector.size();
            ActivityDriversBrowser.Entry localEntry2;
            label1087:
            int i9;
            ActivityDriversBrowser.Entry localEntry3;
            if (i7 >= 0)
            {
              String str2 = ((ActivityDriversBrowser.Entry)localVector.get(i7)).name.toLowerCase();
              if ((!str1.startsWith(str2)) || ((!str1.startsWith(str2.concat(" "))) && (!str1.startsWith(str2.concat("-"))))) {}
            }
            else if (i7 < 2)
            {
              int i8 = localEntry1.name.indexOf(" ");
              if (i8 > 0)
              {
                if (i7 >= 0) {
                  break label1597;
                }
                localEntry2 = new ActivityDriversBrowser.Entry(localEntry1.name.substring(0, i8).trim(), true);
                if (ActivityDriversBrowser.this.data.size() > 0)
                {
                  ActivityDriversBrowser.Entry localEntry7 = (ActivityDriversBrowser.Entry)ActivityDriversBrowser.this.data.lastElement();
                  if ((localEntry7.data == null) && (localEntry7.name.equalsIgnoreCase(localEntry2.name))) {
                    localEntry2.data.add(ActivityDriversBrowser.this.data.remove(-1 + ActivityDriversBrowser.this.data.size()));
                  }
                }
                ActivityDriversBrowser.this.data.add(localEntry2);
                localVector.add(localEntry2);
                i9 = localEntry1.name.indexOf(" ", i8 + 1);
                if (i9 < 0) {
                  i9 = localEntry1.name.indexOf("-", i8 + 1);
                }
                if (i9 > 0)
                {
                  if (i7 >= 1) {
                    break label1611;
                  }
                  localEntry3 = new ActivityDriversBrowser.Entry(localEntry1.name.substring(0, i9).trim(), true);
                  if (localEntry2.data.size() > 0)
                  {
                    ActivityDriversBrowser.Entry localEntry6 = (ActivityDriversBrowser.Entry)localEntry2.data.lastElement();
                    if ((localEntry6.data == null) && (localEntry6.name.equalsIgnoreCase(localEntry3.name))) {
                      localEntry3.data.add(localEntry2.data.remove(-1 + localEntry2.data.size()));
                    }
                    if ((localEntry6.data != null) && (localEntry6.data.size() == 1)) {
                      localEntry2.data.set(-1 + localEntry2.data.size(), localEntry6.data.get(0));
                    }
                  }
                  localEntry2.data.add(localEntry3);
                  localVector.add(localEntry3);
                }
              }
            }
            for (;;)
            {
              int i10 = localEntry1.name.indexOf(" ", i9 + 1);
              if (i10 > 0)
              {
                ActivityDriversBrowser.Entry localEntry4 = new ActivityDriversBrowser.Entry(localEntry1.name.substring(0, i10).trim(), true);
                if (localEntry3.data.size() > 0)
                {
                  ActivityDriversBrowser.Entry localEntry5 = (ActivityDriversBrowser.Entry)localEntry3.data.lastElement();
                  if ((localEntry5.data == null) && (localEntry5.name.equalsIgnoreCase(localEntry4.name))) {
                    localEntry4.data.add(localEntry3.data.remove(-1 + localEntry3.data.size()));
                  }
                  if ((localEntry5.data != null) && (localEntry5.data.size() == 1)) {
                    localEntry3.data.set(-1 + localEntry3.data.size(), localEntry5.data.get(0));
                  }
                }
                localEntry3.data.add(localEntry4);
                localVector.add(localEntry4);
              }
              i7 = -1 + localVector.size();
              if (i7 >= 0) {
                break label1625;
              }
              ActivityDriversBrowser.this.data.add(localEntry1);
              break;
              ActivityDriversBrowser.Entry localEntry8 = (ActivityDriversBrowser.Entry)localVector.remove(i7);
              if ((localEntry8.data.size() != 1) || (localVector.size() <= 0)) {
                break label859;
              }
              ActivityDriversBrowser.Entry localEntry9 = (ActivityDriversBrowser.Entry)localEntry8.data.elementAt(0);
              localEntry8.name = localEntry9.name;
              localEntry8.type_rid = localEntry9.type_rid;
              localEntry8.data = localEntry9.data;
              break label859;
              label1597:
              localEntry2 = (ActivityDriversBrowser.Entry)localVector.get(0);
              break label1087;
              label1611:
              localEntry3 = (ActivityDriversBrowser.Entry)localVector.get(1);
            }
            label1625:
            ((ActivityDriversBrowser.Entry)localVector.get(i7)).data.add(localEntry1);
          }
          ActivityDriversBrowser.access$302(ActivityDriversBrowser.this, null);
          ActivityDriversBrowser localActivityDriversBrowser = ActivityDriversBrowser.this;
          Runnable local1 = new Runnable()
          {
            public void run()
            {
              ActivityDriversBrowser.this.adapter.changeFolder(null);
              ActivityDriversBrowser.this.hideProgress();
            }
          };
          localActivityDriversBrowser.runOnUiThread(local1);
          return;
          label1680:
          if (i11 != -1) {}
        }
      }
    };
    this.wt.start();
  }
  
  public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
  {
    if ((paramInt == 4) && (this.adapter.chain.size() > 0))
    {
      FolderAdapter localFolderAdapter = this.adapter;
      if (this.adapter.chain.size() > 1) {}
      for (Entry localEntry = (Entry)this.adapter.chain.get(-2 + this.adapter.chain.size());; localEntry = null)
      {
        localFolderAdapter.changeFolder(localEntry);
        return true;
      }
    }
    return super.onKeyDown(paramInt, paramKeyEvent);
  }
  
  static class Entry
  {
    public Vector<Entry> data;
    public String name;
    public int type_rid;
    
    public Entry(String paramString, boolean paramBoolean)
    {
      this.name = paramString;
      this.type_rid = 2130837540;
      if (paramBoolean)
      {
        this.data = new Vector();
        this.type_rid = 2130837541;
      }
      if ("..".equals(paramString)) {
        this.type_rid = 2130837573;
      }
    }
  }
  
  class FolderAdapter
    implements ListAdapter
  {
    private Vector<ActivityDriversBrowser.Entry> chain = new Vector();
    private Vector<ActivityDriversBrowser.Entry> entries = new Vector();
    private List<DataSetObserver> observers = null;
    
    public FolderAdapter()
    {
      changeFolder(null);
    }
    
    public boolean areAllItemsEnabled()
    {
      return true;
    }
    
    public void changeFolder(ActivityDriversBrowser.Entry paramEntry)
    {
      Vector localVector1;
      label94:
      int j;
      label105:
      ActivityDriversBrowser.Entry localEntry;
      if (paramEntry != null) {
        if ((this.chain.size() > 1) && (this.chain.get(-2 + this.chain.size()) == paramEntry))
        {
          this.chain.remove(-1 + this.chain.size());
          this.entries.clear();
          if (paramEntry != null) {
            this.entries.add(new ActivityDriversBrowser.Entry("..", true));
          }
          if (paramEntry != null) {
            break label206;
          }
          localVector1 = ActivityDriversBrowser.this.data;
          int i = this.entries.size();
          j = 0;
          if (j >= localVector1.size()) {
            break label227;
          }
          localEntry = (ActivityDriversBrowser.Entry)localVector1.get(j);
          if (localEntry.type_rid != 2130837541) {
            break label214;
          }
          Vector localVector2 = this.entries;
          int k = i + 1;
          localVector2.add(i, localEntry);
          i = k;
        }
      }
      for (;;)
      {
        j++;
        break label105;
        if ((this.chain.size() != 0) && (paramEntry == this.chain.lastElement())) {
          break;
        }
        this.chain.add(paramEntry);
        break;
        this.chain.clear();
        break;
        label206:
        localVector1 = paramEntry.data;
        break label94;
        label214:
        this.entries.add(localEntry);
      }
      label227:
      fireOnChanged();
    }
    
    public void fireOnChanged()
    {
      if (this.observers != null)
      {
        int i = this.observers.size();
        for (int j = 0; j < i; j++) {
          ((DataSetObserver)this.observers.get(j)).onChanged();
        }
      }
    }
    
    public int getCount()
    {
      return this.entries.size();
    }
    
    public Object getItem(int paramInt)
    {
      return this.entries.get(paramInt);
    }
    
    public long getItemId(int paramInt)
    {
      return ((ActivityDriversBrowser.Entry)this.entries.get(paramInt)).name.hashCode() << paramInt + 16;
    }
    
    public int getItemViewType(int paramInt)
    {
      return 0;
    }
    
    public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
    {
      LinearLayout localLinearLayout = (LinearLayout)paramView;
      ImageView localImageView;
      TextView localTextView;
      if (localLinearLayout == null)
      {
        localLinearLayout = new LinearLayout(ActivityDriversBrowser.this);
        localLinearLayout.setOrientation(0);
        localImageView = new ImageView(ActivityDriversBrowser.this);
        localLinearLayout.addView(localImageView, new ViewGroup.LayoutParams(-2, -2));
        localTextView = new TextView(ActivityDriversBrowser.this);
        localTextView.setGravity(16);
        localTextView.setTextSize(1, 18.0F);
        localTextView.setSingleLine();
        localTextView.setTextColor(-986896);
        localLinearLayout.addView(localTextView, new ViewGroup.LayoutParams(-2, -1));
      }
      for (;;)
      {
        int i = ((ActivityDriversBrowser.Entry)this.entries.get(paramInt)).type_rid;
        if ((localImageView.getTag() == null) || (i != ((Integer)localImageView.getTag()).intValue()))
        {
          localImageView.setTag(Integer.valueOf(i));
          localImageView.setImageResource(i);
        }
        localLinearLayout.setTag(Integer.valueOf(paramInt));
        localTextView.setText(((ActivityDriversBrowser.Entry)this.entries.get(paramInt)).name);
        return localLinearLayout;
        localImageView = (ImageView)localLinearLayout.getChildAt(0);
        localTextView = (TextView)localLinearLayout.getChildAt(1);
      }
    }
    
    public int getViewTypeCount()
    {
      return 1;
    }
    
    public boolean hasStableIds()
    {
      return false;
    }
    
    public boolean isEmpty()
    {
      return this.entries.size() == 0;
    }
    
    public boolean isEnabled(int paramInt)
    {
      return true;
    }
    
    public void registerDataSetObserver(DataSetObserver paramDataSetObserver)
    {
      if (this.observers == null) {
        this.observers = new ArrayList();
      }
      if (!this.observers.contains(paramDataSetObserver)) {
        this.observers.add(paramDataSetObserver);
      }
    }
    
    public void unregisterDataSetObserver(DataSetObserver paramDataSetObserver)
    {
      if (this.observers == null) {
        return;
      }
      this.observers.remove(paramDataSetObserver);
    }
  }
}


/* Location:           C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar.jar
 * Qualified Name:     com.dynamixsoftware.printershare.ActivityDriversBrowser
 * JD-Core Version:    0.7.0.1
 */